  <template> 
	<div class="JNPF-common-layout">
		<div class="JNPF-common-layout-center">
			<el-row class="JNPF-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="预案执行人">
							<el-select v-model="query.yazxr" placeholder="预案执行人" clearable filterable>
								<el-option v-for="(item, index) in yazxrOptions" :key="index" :label="item.F_RealName" :value="item.F_Id"  />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
					<el-form-item>
						<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
						<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
					</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<div class="JNPF-common-layout-main JNPF-flex-main">
				<div class="JNPF-common-head">
					<div>
						<!-- <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">
							新增
						</el-button> -->
						<el-button type="text" icon="el-icon-download" @click="exportData()">
							导出
						</el-button>
					</div>
					<div class="JNPF-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"  @click="reset()" />
						</el-tooltip>
						<screenfull :isContainer="true" />
						<el-tooltip effect="dark" content="列设置" placement="top">
							<el-link icon="icon-ym icon-ym-options JNPF-common-head-icon" :underline="false" />
						</el-tooltip>
					</div>
				</div>
				<JNPF-table v-loading="listLoading" :data="list">
					<!-- <el-table-column prop="yaid" label="预案Id" align="left" /> -->
                    <el-table-column prop="yazxrname" label="预案执行人" align="left" />
					<el-table-column prop="yazxsj" label="预案执行时间" align="left" />
                    <el-table-column prop="yatzrname" label="预案停止人" align="left" />
					<!-- <el-table-column label="预案执行人"  prop="yazxr" algin="left">
						<template slot-scope="scope">{{ scope.row.yazxr | dynamicText(yazxrOptions) }}</template>
					</el-table-column> -->
					<el-table-column prop="yatzsj" label="预案停止时间" align="left" />
					<!-- <el-table-column label="预案停止人"  prop="yatzr" algin="left">
						<template slot-scope="scope">{{ scope.row.yatzr | dynamicText(yatzrOptions) }}</template>
					</el-table-column> -->
					
				</JNPF-table>
				<pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="initData" />
			</div>
		</div>
		<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
		<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
	</div>

</template> 
  <script>
    import request from '@/utils/request'
    import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
    import JNPFForm from './Form'
    import ExportBox from './ExportBox'
    import {previewDataInterface} from '@/api/systemData/dataInterface'

    export default {
        components: {JNPFForm, ExportBox},
        data() {
            return {
                    showAll: false,
                query: {
					yazxr:undefined,

                },
                defaultProps: {
                    children: 'children',
                    label: 'fullName'
                },
                list: [],
                listLoading: true,
                total: 0,
                listQuery: {
					// currentPage: 1,
					// pageSize: 20,
                    page: 1,
					limit: 100,

                    sort: "desc",
                    sidx: "",
                },
                formVisible: false,
                exportBoxVisible: false,
                columnList: [
					{prop: 'yaid', label: '预案Id'},
					{prop: 'yazxsj', label: '预案执行时间'},
					{prop: 'yazxr', label: '预案执行人'},
					{prop: 'yatzsj', label: '预案停止时间'},
					{prop: 'yatzr', label: '预案停止人'},

                ],
				yazxrOptions:[],
				yatzrOptions:[],


            }
        },
        computed: {},
        created() {
			this.initData();

		this.getyazxrOptions();
		this.getyatzrOptions();

        },
        methods: {
		getyazxrOptions()
		{
			previewDataInterface('8bca424f16d6448ab09e57a028853aa9').then(res => {
				this.yazxrOptions = res.data
			})
		},
		getyatzrOptions()
		{
			previewDataInterface('8bca424f16d6448ab09e57a028853aa9').then(res => {
				this.yatzrOptions = res.data
			})
		},


            initData() {
                this.listLoading = true;
                let query = {
                    ...this.listQuery,
                    ...this.query
                };
                request({
                    url: `/api/System/yazxb`,
                    method: 'get',
                    data: query
                }).then(res => {
                    let listData = JSON.parse(res.msg);
                    this.list = listData.data
                    // this.total = res.data.pagination.total
                    this.total = listData.data.length;
                    this.listLoading = false
                    this.$nextTick(() => {
                        this.tableHeight = "100%"
                    });
                })
            },
            handleDel(id) {
                this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                    type: 'warning'
                }).then(() => {
                    request({
                        url: `/api/System/yazxb/${id}`,
                        method: 'DELETE'
                    }).then(res => {
                        this.$message({
                            type: 'success',
                            message: res.msg,
                            onClose: () => {
                                this.initData()
                            }
                        });
                    })
                }).catch(() => {
                });
            },
            addOrUpdateHandle(id,isDetail) {
                this.formVisible = true
                this.$nextTick(() => {
                    this.$refs.JNPFForm.init(id,isDetail)
                })
            },
            exportData() {
                this.exportBoxVisible = true
                this.$nextTick(() => {
                    this.$refs.ExportBox.init(this.columnList)
                })
            },
            download(data) {
                let query = {...data, ...this.listQuery, ...this.query}
                request({
                    url: `/api/System/yazxb/Actions/Export`,
                    method: 'POST',
                    data: query
                }).then(res => {
                    if (!res.data.url) return
                    window.location.href = this.define.comUrl + res.data.url
                    this.$refs.ExportBox.visible = false
                    this.exportBoxVisible = false
                })
            },
            search() {
                this.listQuery = {
					page: 1,
					limit: 100,

                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            },
            refresh(isrRefresh) {
                this.formVisible = false
                if (isrRefresh) this.reset()
            },
            reset() {
                for (let key in this.query) {
                    this.query[key] = undefined
                }
                this.listQuery = {
					page: 1,
					limit: 100,

                    sort: "desc",
                    sidx: "",
                }
                this.initData()
            }
        }
    }
</script>